/*
 * Error.java
 *
 * Created on 23 de Junho de 2007, 23:34
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.jerm.Interface;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 *
 * @author tiagofalcao
 */
public class Error extends JFrame{
    
    /** Creates a new instance of Error */
    public Error(String Mensagem) {
        super("ERRO");
        
        setIconImage(new ImageIcon(Principal.class.getResource("Icones/error.png")).getImage());//Icone
        setDefaultLookAndFeelDecorated(false); //Tema de Janela igual ao do Windows

        //Faz a Janela Ficar Identada 50 pixels para cada borda da tela
        int w = 300;
        int h = 200;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width - w)/2,
                (screenSize.height - h)/2,
                  w,h);

        //Cria o Desktop de Janelas
        //desktop = new JDesktopPane(); //a specialized layered pane
        //setContentPane(desktop);
        
        //Aparetemente fecha tudo sem pedir para salvar
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        
        Container c = this.getContentPane();
        c.setLayout(new BorderLayout());
        
        AbstractAction action = new AbstractAction("OK"){
                public void actionPerformed(ActionEvent e) {
                    setVisible(false);
                    dispose();
                }
        };
        JButton ok = new JButton("");
        ok.setAction (action);
        
        JTextArea t=new JTextArea();
        t.setEditable(false);
        t.setOpaque(false);
        t.setBorder(null);
        t.setText(Mensagem);
        
        c.add(t,BorderLayout.CENTER);
        c.add(ok,BorderLayout.SOUTH);
        setVisible(true);
    }
    
//    public void start(){
//        setVisible(true);
//        while(true){
//            
//        }
//    }
    
    
    public static void main(String[] args) 
    {
        new Error("Ola").setVisible(true);

    }
}
